package com.smartwebx.ha.web.admin.module.screen.report;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.dataresolver.Param;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.smartwebx.ha.biz.assign.HaReportManager;
import com.smartwebx.ha.dal.assign.dao.HaReportUserMapper;
import com.smartwebx.ha.web.admin.common.util.HaTool;
/**
 * 
 * 创建人：Dream~天涯 
 * 创建时间：2015-4-28 下午2:31:21
 * 邮箱：154494796@qq.com
 * 备注：
 */
public class AjaxUserToReprtData {
	@Autowired
	private HaReportUserMapper haReportUserMapper;
	@Autowired
	private HttpServletResponse response;
	@Autowired
	private HaReportManager haReportManager;
	@Autowired
	private HttpServletRequest request;
	@Autowired
	private HttpSession session;
	public void execute(@Param("treeUserId") String treeUserId, @Param("reportType") String reportType) throws IOException{
		Cookie[] cookies = request.getCookies();
		String userId = HaTool.getCookie(request,cookies,"userId");
		String roleId = HaTool.getCookie(request,cookies,"roleId");
		String areaId = HaTool.getCookie(request,cookies,"areaId");
		String code = HaTool.getCookie(request,cookies,"code");
		response.setContentType("application/json");
		PrintWriter out=response.getWriter();
		ObjectMapper mapper=new ObjectMapper();
		mapper.writeValue(out, haReportManager.getTree(Integer.parseInt(userId),Integer.parseInt(roleId),Integer.parseInt(areaId), code, treeUserId, Integer.parseInt(reportType)));

		
	}
}
